import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:hc_center/conf/ResConf.dart';
import 'package:hc_center/conf/StrConf.dart';

import 'start_state.dart';

Widget buildView(StartState state, Dispatch dispatch, ViewService viewService) {
  return Scaffold(
    body: FutureBuilder(
      future: _checkContextInit(
        Stream<double>.periodic(Duration(milliseconds: 50),
                (x) => MediaQuery.of(viewService.context).size.height),
      ),
      builder: (_, snapshot) {
        return SafeArea(
          child: Column(mainAxisAlignment: MainAxisAlignment.start, children: [
            Expanded(child: Container()),
            SizedBox(
                width: ScreenUtil().screenWidth,
                height: 300.h,
                child: Image.asset(ResConf.mimi)),
            Expanded(child: SizedBox()),
            Text(
              StrConf.appName,
              style: TextStyle(fontSize: 50.sp, fontWeight: FontWeight.w700),
            ),
            SizedBox(height: 20.h),
            Text(
              StrConf.appWlc,
              style: TextStyle(fontSize: 28.sp, fontWeight: FontWeight.w500),
            ),
            Expanded(child: Container())
          ]),
        );
      },
    ),
  );
}

Future<double> _checkContextInit(Stream<double> source) async {
  await for (double value in source) {
    if (value > 0) {
      return value;
    }
  }
  return 0.0;
}

